set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO

If exists(select 1 from sysobjects where xtype = 'P' and name = 'Rpt_Cotizacion')
Begin
   Drop proc Rpt_Cotizacion
End

GO

CREATE        Proc [dbo].[Rpt_Cotizacion]
	(@Emp_Id smallint,
	 @Cotizacion_Id int) AS
Begin
	Set nocount on

	Select cliente_nombre, cliente_contacto, cliente_contacto_telefono, cliente_telefono,
		   linea_nombre, cotizacion_base, cotizacion_altura, material_nombre,
		   cotizacion_totalUSD, vendedor_nombre, vendedor_email, vendedor_telefono, vendedor_beeper
	From Cotizacion c
	Inner join Cliente t 
	   on (c.emp_Id = t.emp_id and c.cliente_id = t.cliente_id)
	Inner join Linea l 
	   on (c.emp_Id = l.emp_id and c.linea_id = l.linea_id)
    Inner join Material m 
	   on (c.emp_Id = m.emp_id and c.material_id = m.material_id)
	Inner join Vendedor v
	   on (c.emp_id = v.emp_id and c.vendedor_id = v.vendedor_id)
	Where c.emp_id = @Emp_Id
      and c.cotizacion_id = @Cotizacion_Id

	Set nocount on
End
 